#include "tinyxml2.h"
#include <iostream>

using namespace tinyxml2;
using namespace std;

int main( int argc, const char ** argv )
{
    XMLDocument doc;
    XMLElement *root = doc.NewElement("Lanqiao");
    XMLDeclaration *del = doc.NewDeclaration();
    doc.InsertFirstChild(del);
    doc.InsertEndChild(root);
    
    XMLElement *teaEle = root->InsertNewChildElement("Teacher");
    teaEle->InsertNewText("负责 C++ 技术指导");
    teaEle->SetAttribute("Name", "李江军");
    teaEle->SetAttribute("sex", "男");

    XMLElement *stuEle = root->InsertNewChildElement("Student");
    XMLElement *stu1 = stuEle->InsertNewChildElement("Member");
    stu1->SetAttribute("sex", "男");
    stu1->SetText("黄小东");
    XMLElement *stu2 = stuEle->InsertNewChildElement("Member");
    stu2->SetAttribute("sex", "男");
    stu2->SetText("高云鹏");
    XMLElement *stu3 = stuEle->InsertNewChildElement("Member");
    stu3->SetAttribute("sex", "女");
    stu3->SetText("孙畅");
    XMLElement *stu4 = stuEle->InsertNewChildElement("Member");
    stu4->SetAttribute("sex", "男");
    stu4->SetText("张训");
    XMLElement *stu5 = stuEle->InsertNewChildElement("Member");
    stu5->SetAttribute("sex", "男");
    stu5->SetText("王政");
    XMLElement *stu6 = stuEle->InsertNewChildElement("Member");
    stu6->SetAttribute("sex", "男");
    stu6->SetText("孙浩博");
    XMLElement *stu7 = stuEle->InsertNewChildElement("Member");
    stu7->SetAttribute("sex", "男");
    stu7->SetText("张逸凡");

    doc.SaveFile("write.xml");

    cout << "XML 文件保存完毕！" << endl;

    return 0;
}